import { LocalStorage, SessionStorage } from 'quasar';
import Vue from 'vue';

interface Storage {
  getItem: (key: string) => any;
  setItem: (key: string, value: any) => void;
  removeItem: (key: string) => void;
}

export const localStorage: Storage = {
  getItem: (key: string) => {
    return LocalStorage.getItem(key);
  },

  setItem: (key: string, val: any) => {
    // console.log(Vue.prototype);
    // if (Vue.prototype.$bus) {
    //   Vue.prototype.$bus.$emit('setitem', { key, val });
    // }
    return LocalStorage.set(key, val);
  },
  removeItem: (key: string) => {
    return LocalStorage.remove(key);
  }
};
